<!DOCTYPE html><html><head><title>Backbone Model Test</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="../../lib/jquery.min.js"></script><script src="../../lib/underscore.js"></script><script src="../../lib/backbone.js"></script></head><body><script type="text/javascript">var UserModel = Backbone.Model.extend({
    urlRoot: '/user',
    defaults: {
        name: '',
        email: ''
    }
});
var user = new UserModel({id: 1});
var userDetails = {
    name: 'Thomas',
    email: 'thomasalwyndavis@gmail.com'
};
user.save(userDetails, {
    success: function (user) {
        alert(user.toJSON());
    },
    error: function (user) {
        alert("save" + user.get("id"));
    }
})

var user2 = new UserModel();
var userDetails = {
    id: 1,
    name: 'Thomas',
    email: 'thomasalwyndavis@gmail.com'
};
user2.destroy({
    success: function (user) {
        alert("delete successfully");
    },
    error: function (user) {
        alert("delete error " + user.get("id"));
    }
})</script></body></html>